<!DOCTYPE html>
<html>

<head>
    <meta charset="UTF-8">
    <title>欢迎页面-X-admin2.0</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport"
          content="width=device-width,user-scalable=yes, minimum-scale=0.4, initial-scale=0.8,target-densitydpi=low-dpi"/>
    <link rel="shortcut icon" href="/favicon.ico" type="image/x-icon"/>
    <link rel="stylesheet" href="./css/font.css">
    <link rel="stylesheet" href="./css/xadmin.css">
    <script type="text/javascript" src="./js/jquery.min.js"></script>
    <script src="./js/common.js"></script>
    <script type="text/javascript" src="./lib/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="./js/xadmin.js"></script>
    <!-- 让IE8/9支持媒体查询，从而兼容栅格 -->
    <!--[if lt IE 9]>
    <script src="./js/html5.min.js"></script>
    <script src="./js/respond.min.js"></script>
    <![endif]-->
    <script>
        var baseUrl = parent.baseUrl;
        var env = $.getUrlParam("env");
        var gateway = $.getUrlParam("gateway");
        var id = $.getUrlParam("id");
        var serviceId = id;
    </script>
</head>

<body class="layui-anim layui-anim-up">
<div class="x-nav">
    <a class="layui-btn layui-btn-small" style="line-height:1.6em;margin-top:3px;float:right"
       href="javascript:location.replace(location.href);" title="刷新">
        <i class="layui-icon" style="line-height:30px">ဂ</i></a>
</div>
<div class="x-body">
    <xblock>
        <button class="layui-btn" onclick="openAddAlertUserWin()"><i
                class="layui-icon"></i>添加
        </button>
    </xblock>
    <table class="layui-table">
        <thead>
        <tr>
            <th>用户名</th>
            <th>手机号</th>
            <th>邮箱</th>
            <th>备注</th>
            <th>创建时间</th>
            <th>操作</th>
        </tr>
        </thead>
        <tbody id="alertUserListView">

        </tbody>
    </table>

</div>
<script>
    function openAddAlertUserWin() {
        x_admin_show('添加组告警用户', './alert-service-group-user-add.html?gateway=' + gateway + "&env=" + env + "&id=" + id, 800, 400);
    }
</script>

<script>
    layui.use(['form', 'layer'], function () {
        $ = layui.jquery;
        var form = layui.form
            , layer = layui.layer;

        //监听提交
        form.on('submit(sreach)', function (data) {
            var url = "./alert-service-group-user-list.html?env=" + env + "&gateway=" + gateway;
            window.location.href = url;
            return false;
        });

    });
</script>

<script>

    function alertUser_del(obj, id) {
        layer.confirm('确认要删除吗？', function (index) {
            $.ajax({
                url: baseUrl + "/servcieGateway/alertUserRouteService/delete/" + id + "/" + serviceId + "/?env=" + env + "&gateway=" + gateway,
                data: "",
                contentType: 'application/json;charset=utf-8',
                dataType: "JSON",
                async: false,
                type: "GET",
                success: function (respData) {
                    if (respData.respCode === '0000') {
                        //发异步删除数据
                        $(obj).parents("tr").remove();
                        layer.msg('已删除!', {icon: 1, time: 1000});

                    } else {
                        layer.msg(respData.respDesc, {
                            icon: 2,
                            time: 2000 //2秒关闭（如果不配置，默认是3秒）
                        }, function () {
                            //do something
                        });
                    }
                }
            });
        });
    }
</script>
<script>var _hmt = _hmt || [];
(function () {
    var hm = document.createElement("script");
    hm.src = "https://hm.baidu.com/hm.js?b393d153aeb26b46e9431fabaf0f6190";
    var s = document.getElementsByTagName("script")[0];
    s.parentNode.insertBefore(hm, s);
})();</script>
</body>


<script>
    layui.use(['laytpl', 'layer'], function () {
        var laytpl = layui.laytpl;
        var layer = layui.layer;

        $.ajax({
            url: baseUrl + "/servcieGateway/routeService/detail/" + id + "/?gateway=" + gateway + "&env=" + env,
            data: "",
            contentType: 'application/json;charset=utf-8',
            dataType: "JSON",
            async: false,
            type: "GET",
            success: function (respData) {
                if (respData.respCode === '0000') {
                    var data = {
                        "list": respData.data.alertUsers
                    };

                    var getTpl = alertUserListViewScript.innerHTML
                        , view = document.getElementById('alertUserListView');
                    laytpl(getTpl).render(data, function (html) {
                        view.innerHTML = html;
                    });
                } else {
                    layer.msg(respData.respDesc, {
                        icon: 2,
                        time: 2000 //2秒关闭（如果不配置，默认是3秒）
                    }, function () {
                        //do something
                    });
                }
            }
        });
    });
</script>


<script id="alertUserListViewScript" type="text/html">
    {{# layui.each(d.list, function(index, item){ }}

    <tr>
        <td>{{ item.username }}</td>
        <td>{{ item.phoneNo }}</td>
        <td>{{ item.email }}</td>
        <td>{{ item.comment }}</td>
        <td>{{ item.createTime }}</td>

        <td class="td-manage">
            <a title="删除" onclick="alertUser_del(this,'{{ item.id }}')" href="javascript:;">
                <i class="layui-icon">&#xe640;</i>
            </a>
        </td>
    </tr>

    {{# }); }}
</script>

</html>